﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BuXiaChu.OrderDishes.Model;
using BuXiaChu.OrderDishes.BLL;

namespace BuXiaChu.OrderDishes.Web.Admin.Modules.Restaurant
{
    public partial class DishesList : System.Web.UI.UserControl
    {
        protected List<DishesCatModel> DishesCatList = null;

        public List<DishesModel> PageDataList
        {
            get;
            set;
        }

        public int PageIndex
        {
            set;
            get;
        }

        public int PageSize
        {
            get;
            set;
        }

        public int PageCount
        {
            get;
            set;
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            PageBarBottom.PbModel = new PageBarModel();
            PageBarBottom.PbModel.CurrentIndex = PageIndex;
            PageBarBottom.PbModel.Size = PageSize;
            PageBarBottom.PbModel.Count = PageCount;
            if (PageDataList.Count > 0)
            {
                DishesCatList = RestaurantManager.GetDishesCatByRestaurantId(PageDataList[0].RestaurantId);
            }
        }

        protected string GetDishesCatName(int id)
        {
            var result = "";
            foreach (var item in DishesCatList)
            {
                if (item.CatID == id)
                {
                    result = item.Name;
                    break;
                }
            }
            return result;
        }
    }
}